package ig.util.ejb;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

/**
 * Define caracteristicas y metodos utiles que pueden llegar a ser utilizados en los
 * beans de entidad y session que conformen la aplicacion.
 * @author lfgarcia
 */

public class IGBean {

	public static final String INITIAL_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
	protected Connection conn = null;
        protected Connection conn1 = null;
	protected PreparedStatement pstmt1 = null;
	protected PreparedStatement pstmt2 = null;
	protected PreparedStatement pstmt3 = null;
	protected PreparedStatement pstmt4 = null;
	protected PreparedStatement pstmt5 = null;

        
	public Connection getConexion(String datasource) throws NamingException, SQLException{
		Context ctx = new InitialContext();
		DataSource ds = (DataSource)ctx.lookup("java:/"+datasource);
                Connection c=  ds.getConnection();
                return c;
	}
        
}

